package util;

import java.sql.*;

public class DBUtil {
    public static Connection getConnection() {
        Connection conn = null;
        try {
            conn = DriverManager.getConnection(ConfigUtil.getProp("url"), ConfigUtil.getProp("user"), ConfigUtil.getProp("password"));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return conn;
    }

    public static void closeConnection(Connection conn, PreparedStatement pst, Statement st, ResultSet rs) {
        try {
            if (rs != null) {
                rs.close();
            }
            if (st != null) {
                st.close();
            }
            if (pst != null) {
                pst.close();
            }
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
